'use strict';
//对数组进行排序
function arrSort(){
var arr = [5,6,8,7,4,2,6,8,4];
arr.sort(function(x,y){
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }else{
        return 0;
    }
});
console.log(arr);
};
function a(){
    var sum = 0;
var arr = [1, 3, 5, 7, 9];
arr.reduce(function (x, y) {
    sum = x + y;
    return sum;
}); // 25
return sum;
};
console.log(a());



var fn = x => {
    if(x > 0) {
        return x * x;
    }
    if(x < 0) {
        return -x * -x;
    }
};


function* fib(max) {
    var
        t,
        a = 0,
        b = 1,
        n = 0;
    while (n < max) {
        yield a;
        [a, b] = [b, a + b];
        n ++;
    }
    return;
}

for(var x of fib(10)){
    console.log(x);
};
function coo(name) {
    console.log('name='+name);
  };
module.exports = coo;
module.exports = arrSort;
